<?php
namespace app\common\model;

use think\Model;


class City extends Model
{
   
   
    protected $autoWriteTimestamp = true;


    public function getFirstCity($parentId=0) {
        $data = [
            'parent_id' => $parentId,
             // 'status' => ['neq',-1]
        ];
        $order = [
            'listorder' => 'desc',
            'id' =>'desc'
        ];
        $result = $this->where($data)
                    ->order($order)
                    ->paginate(15); 
         return $result;        


    }

    // getNormalFirstCity
    public function getNormalFirstCity() {
           $data = [
              'status' =>1,
              'parent_Id' => 0
           ];
           $order = [
             'id' => 'desc'
           ]; 
           $result = $this->where($data)
                          ->order($order)
                          ->select(); 


             return $result;
    }     

    public function add($data) {
      
        $data['status'] = 1;
        $data['uname'] = $data['name'];
       return  $this->save($data);
    }

    public function getNormalCityByParentId($parentId=0) {
        $data = [
            'parent_id' => $parentId,
             'status' => 1
        ];
        $order = [
            'listorder' => 'desc',
            'id' =>'desc'
        ];
        $result = $this->where($data)
                    ->order($order)
                    ->select(); 
         return $result;           
    
    }
}